package com.lifeng.db;

import com.lifeng.dto.UserDto;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class DB {
    public static Map<Integer,UserDto> data = new HashMap<Integer, UserDto>();

    public static void save(UserDto userDto){
        data.put(userDto.getId(),userDto);
    }

    public static UserDto getById(Integer id){
        return data.get(id);
    }

    public static List<UserDto> list(){
        return data.values().stream().collect(Collectors.toList());
    }
}
